package com.wx.enums;

import com.google.common.collect.Lists;
import com.google.common.collect.Maps;

import java.util.Arrays;
import java.util.List;
import java.util.Map;

/**
 * <p>Title:      PatientStatusEnum. </p>
 * <p>Description 患者状态 </p>
 * <p>Copyright: Copyright (c) 2016</p>
 * <p>Company:    医百科技有限公司 </p>
 *
 * @author         <a href="yangwensheng@100doc.com.cn"/>杨文生</a>
 * @since      2021/3/2 17:50
 */
public enum PatientStatusEnum {

    /**
     * 未审核(未入组)
     */
    NOT_JOIN_GROUP(0, "未审核(未入组)"),
    /**
     * 在组
     */
    IN_GROUP(1, "在组"),
    /**
     * 脱组
     */
    LEAVE_GROUP(2, "脱组"),

    /**
     * 失联
     */
    LOST_CONTACT(3, "失联"),
    ;

    int key;
    String desc;

    PatientStatusEnum(int key, String desc) {
        this.key = key;
        this.desc = desc;
    }

    public int getKey() {
        return key;
    }

    public void setKey(int key) {
        this.key = key;
    }

    public String getDesc() {
        return desc;
    }

    public void setDesc(String desc) {
        this.desc = desc;
    }

    /**
     * 获取key获取value
     * @param key key
     * @return value
     */
    public static String getDesc(int key) {
        for (PatientStatusEnum ele : PatientStatusEnum.values()) {
            if (ele.getKey() == key){
                return ele.getDesc();
            }
        }
        return null;
    }

    public static Integer getKey(String desc) {
        for (PatientStatusEnum ele : PatientStatusEnum.values()) {
            if (ele.getDesc().equals(desc)){
                return ele.getKey();
            }
        }
        return null;
    }

    /**
     * 根据key获取该对象
     * @param key key
     * @return this
     */
    public static PatientStatusEnum getEnum(int key) {
        for (PatientStatusEnum ele : PatientStatusEnum.values()) {
            if (ele.getKey() == key){
                return ele;
            }

        }
        return null;
    }

    /**
     * 获取List集合
     * @return List
     */
    public static List<PatientStatusEnum> getList(){
        return Arrays.asList(PatientStatusEnum.values());
    }


    /**
     * 获取map类型集合
     * @return Map类型List集合
     */
    public static List<Map<String, String>> getMap2List() {
        List<Map<String, String>> list = Lists.newArrayList();
        for (PatientStatusEnum ele : PatientStatusEnum.values()) {
            Map<String, String> map = Maps.newHashMap();
            map.put("key", String.valueOf(ele.getKey()));
            map.put("value", ele.getDesc());
            list.add(map);
        }
        return list;
    }
}
